<template>
  <div class="wo-count-down-wrap">
    <div class="wo-count-down-explain" v-if="explain">{{explain}}</div>
    <yd-countdown class="wo-count-down" :time="time" :timetype="timeType" :done-text="doneText">
      <div class="wo-item">
        <span class="wo-time">{%d0}{%d1}{%d2}</span>
        <span class="wo-label">天</span>
      </div>
      <div class="wo-dot"></div>
      <div class="wo-item">
        <span class="wo-time">{%h1}{%h2}</span>
        <span class="wo-label">时</span>
      </div>
      <div class="wo-dot"></div>
      <div class="wo-item">
        <span class="wo-time">{%m1}{%m2}</span>
        <span class="wo-label">分</span>
      </div>
      <div class="wo-dot"></div>
      <div class="wo-item">
        <span class="wo-time">{%s1}{%s2}</span>
        <span class="wo-label">秒</span>
      </div>
    </yd-countdown>
  </div>
</template>

<script>
  import {VueExtend} from 'godspen-lib'
  import {CountDown} from 'vue-ydui/dist/lib.px/countdown'

  export default {
    mixins: [VueExtend.mixin],
    name: 'CountDown',
    label: process.env.LABEL,
    style: process.env.STYLE,
    stack: null, // 是否是堆叠模式 ，false：孩子元素会按楼层一个个向下排布， true: 孩子元素绝对定位，随意放置位置
    childLimit: 9999,  // 孩子元素最大限制数
    leaf: true, // 是否是叶子节点，为true的时候该节点下面不能添加节点
    props: {
      explain: {
        type: String,
        default: '结束时间',
        editor: {
          label: '描述文案',
          desc: '倒计时名称或描述文案',
          type: 'input'
        }
      },
      timeType: {
        type: String,
        default: 'datetime',
        editor: {
          label: '时间类型',
          desc: '设置时间参数类型',
          type: 'enum',
          defaultList: {
            'datetime': '日期时间',
            'second': '剩余秒数',
            'timestamp': '时间戳'
          }
        }
      },
      time: {
        type: String,
        default: '',
        editor: {
          label: '结束时间',
          desc: '设置倒计时结束时间',
          type: 'input'
        }
      },
      doneText: {
        type: String,
        default: '活动已结束',
        editor: {
          label: '结束文案',
          desc: '倒计时结束后显示文案',
          type: 'input'
        }
      }
    },
    components: {
      [CountDown.name]: CountDown
    },
    computed: {
    },
    editorMethods: {
    },
    methods: {
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus" type="text/stylus" scoped>
.wo-count-down-wrap {
  width: 100%;
  height: auto;
  text-align: center;
}
.wo-count-down-explain {
  font-size: 12px;
  line-height: 25px;
}
.wo-count-down {
  display: block;
  line-height: 0;
}
.wo-item {
  display: inline-block;
  background-color: rgba(0, 0, 0, .8);
  padding: 5px;
  border-radius: 5px;
  vertical-align: bottom;
  color: #fff;
}
.wo-time {
  display: block;
  height: 20px;
  line-height: 20px;
  font-size: 16px;
}
.wo-label {
  display: block;
  height: 10px;
  line-height: 10px;
  font-size: 8px;
}
.wo-dot {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 40px;
  vertical-align: bottom;
}
.wo-dot:before, .wo-dot:after {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #000;
}
.wo-dot:before {
  top: 25%;
}
.wo-dot:after {
  bottom: 25%;
}
</style>
